// GeneralMath.h: interface for the GeneralMath class.
//
//////////////////////////////////////////////////////////////////////

#if !defined GENERALMATH_H
#define GENERALMATH_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// define standard values of PI
#ifdef PI
#undef PI
#undef PI_2		// PI/2 for efficiency
#undef PI_4		// PI/4 for efficiency
#endif
const double PI   = 3.14159265358979323846;
const double PI_2 = 1.57079632679489661923;
const double PI_4 = 0.78539816339744830962;

/** return the minimum of two values */
template<typename T>
inline T absolute(T v) { return v<(T)0?-v:v; }

/** return the minimum of two values */
template<typename T>
inline T minimum(T lhs,T rhs) { return lhs<rhs?lhs:rhs; }

/** return the maximum of two values */
template<typename T>
inline T maximum(T lhs,T rhs) { return lhs>rhs?lhs:rhs; }

template<typename T>
inline T clampTo(T v,T minimum,T maximum) { return v<minimum?minimum:v>maximum?maximum:v; }

template<typename T>
inline T clampAbove(T v,T minimum) { return v<minimum?minimum:v; }

template<typename T>
inline T clampBelow(T v,T maximum) { return v>maximum?maximum:v; }

template<typename T>
inline T sign(T v) { return v<(T)0?(T)-1:(T)1; }

template<typename T>
inline T square(T v) { return v*v; }

template<typename T>
inline T signedSquare(T v) { return v<(T)0?-v*v:v*v;; }

inline float inDegrees(float angle) { return angle*(float)PI/180.0f; }
inline double inDegrees(double angle) { return angle*PI/180.0; }

template<typename T>
inline T inRadians(T angle) { return angle; }

inline float DegreesToRadians(float angle) { return angle*(float)PI/180.0f; }
inline double DegreesToRadians(double angle) { return angle*PI/180.0; }

inline float RadiansToDegrees(float angle) { return angle*180.0f/(float)PI; }
inline double RadiansToDegrees(double angle) { return angle*180.0/PI; }



class GeneralMath  
{
	
public:
	GeneralMath();
	virtual ~GeneralMath();

};

#endif // GENERALMATH_H
